package com.zjq.jwt;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * @author zjq
 * @date 2020/3/12 10:34
 * <p>title:配置类</p>
 * <p>company:zjhcsoft</p>
 * <p>description:</p>
 */
@Configuration
public class SystemConfig extends WebMvcConfigurationSupport {

    @Autowired
    private JwtInterceptor jwtInterceptor;

    /**
     * 添加拦截器的配置
     */
    @Override
    protected void addInterceptors(InterceptorRegistry registry) {

        registry.addInterceptor(jwtInterceptor).
                //拦截请求
                addPathPatterns("/**").
                //设置不拦截请求
                excludePathPatterns("/user/sms/login"
                        ,"/manage/user/login"
                        ,"/smsCode/send"
                        ,"/wechat/**");
    }

    @Bean
    public JwtUtil getJwtUitl(){
        return new JwtUtil();
    }
}